/*
 * demo1.cpp
 *
 *  Created on: 2012-8-20
 *      Author: huangyansheng
 */

#include <iostream>
#include <gtest/gtest.h>

using namespace std;

class Shop{
public:
int total_6(int price,int number);
};
//计算商品总价
int Shop::total_6(int price,int number)
{
	if(price<0)
		return -1;
	else if(number<0)
		return -1;
	else
		return price*number;
}


TEST(total_6,price1){
	Shop dd;
	EXPECT_EQ(10,dd.total_6(1,10));
	EXPECT_EQ(10,dd.total_6(2,5));
	EXPECT_EQ(10,dd.total_6(5,2));
	EXPECT_EQ(10,dd.total_6(10,1));
}
TEST(total_6,price_zero){
	Shop dd;
	EXPECT_EQ(0,dd.total_6(0,10));
	EXPECT_EQ(0,dd.total_6(10,0));
}
TEST(total_6,price_negative){
	Shop dd;
	EXPECT_EQ(-1,dd.total_6(-1,10));
	EXPECT_EQ(-1,dd.total_6(10,-1));
	EXPECT_EQ(-1,dd.total_6(-10,-1));
}


class ShopTest_6 : public ::testing::Test {
public:
	Shop *dd;
	static void SetUpTestCase()
	{
		cout<<"SetUpTestCase"<<endl;
	}
	void SetUp()
	{
		dd=new Shop;
	}
	void TearDown()
	{
		delete dd;
	}
	static void TearDownTestCase()
	{
		cout<<"TearDownTestCase"<<endl;
	}
};
TEST_F(ShopTest_6,price1){
	EXPECT_EQ(10,dd->total_6(1,10));
	EXPECT_EQ(10,dd->total_6(2,5));
	EXPECT_EQ(10,dd->total_6(5,2));
	EXPECT_EQ(10,dd->total_6(10,1));
}
TEST_F(ShopTest_6,price_zero){
	EXPECT_EQ(0,dd->total_6(0,10));
	EXPECT_EQ(0,dd->total_6(10,0));
}
